package com.atguigu.flink0922.chapter05.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/3/2 10:50
 */
public class Flink01_Source_Collection {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
    
        final List<Integer> list = Arrays.asList(10, 20, 30, 40, 50);
    
//        final DataStreamSource<Integer> sourceStream = env.fromCollection(list);
        final DataStreamSource<Integer> sourceStream = env.fromElements(1, 2, 3, 4, 5);
    
        sourceStream.print();
        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
